#ifndef CFGCOM_H
#define CFGCOM_H

#include <QDialog>

#include <QSerialPort>
#include <QSerialPortInfo>
#include <QTimer>


namespace Ui {
class CfgCom;
}

class CfgCom : public QDialog
{
    Q_OBJECT

public:
    explicit CfgCom(QWidget *parent = nullptr);
    ~CfgCom();

public:
    void uiInit();

    void searchPort();

    void serialPortInit();

    void setState(QString state,QString color);

    QString timeStamp();
Q_SIGNALS:
    void sendData(QByteArray data);

public Q_SLOTS:
    void writeData(QString data);

    void cacheDate();

private slots:
    void on_btn_refresh_clicked();

    void on_cb_com_currentTextChanged(const QString &arg1);

    void on_btn_start_clicked();

    void on_cb_baud_currentTextChanged(const QString &arg1);

    void on_btn_stop_clicked();

private:
    Ui::CfgCom *ui;
    QSerialPort * serialPort;

    //数据缓存定时器
    QTimer *tempTimer;
    bool enableCache;
    QByteArray tempArrayData;

    QString portName;
    qint64 baud;
};

#endif // CFGCOM_H
